﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NS.Utilities;
using NS.BLL.Systems;

public partial class Platform_CarTypeModify : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            DataShow();
        }
    }
    private void DataShow()
    {
        object[] CarType = UtilityService.GetFieldValueByPK("CarType", "TypeName,OrderID", "TypeID", Request.QueryString["ID"].ToString());
        if (CarType.Length > 0)
        {
            txtTypeName.Text = CarType[0].ToString();
            txtOrderID.Text = CarType[1].ToString();
        }
    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (ImageUpload.HasFile)
        {
            string logo = FileHelper.SaveFile(ImageUpload, "../wechat/carlogo/");
            if (UtilityService.UpdateFieldByPK("CarType", "TypeName,Logo,OrderID", new Object[] { txtTypeName.Text.Trim(), logo.Substring(10), txtOrderID.Text.Trim() }, "TypeID", Request.QueryString["ID"]) > 0)
            {
                MessageBox.AppendScript(this, "$(':input[id$=\"btnBindData\"]', window.parent.document.body).click();");
            }
        }
        else
        {
            if (UtilityService.UpdateFieldByPK("CarType", "TypeName,OrderID", new Object[] { txtTypeName.Text.Trim(), txtOrderID.Text.Trim() }, "TypeID", Request.QueryString["ID"]) > 0)
            {
                MessageBox.AppendScript(this, "$(':input[id$=\"btnBindData\"]', window.parent.document.body).click();");
            }
        }
    }
}